import React from 'react'
import { Dropdown, Icon, Button } from 'antd'
import PropTypes from 'prop-types'
import s from './index.less'

const Comp=({ btns = [] }) => {
  const overlay = (
    <div className={s['btns']}>
      {btns.map(({ isShow = true, ...v }, i) => {
        return (
          isShow && <Button key={i} onClick={v.click}>{v.name}</Button>
        )
      })}
    </div>
  )
  return (
    <Dropdown
      overlay={overlay}
      getPopupContainer={() => document.getElementById('opt-btn-box')}
      // trigger={['click']}
    >
      <Icon type="ellipsis" className={s['btns-icon']}/>
    </Dropdown>
  )
}
Comp.propTypes={
  btns: PropTypes.arrayOf(
    PropTypes.shape({
      click: PropTypes.func.isRequired,
      name: PropTypes.string.isRequired,
      isShow: PropTypes.bool
    })
  )
}

export default Comp
